home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / compile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-10  |  1.8 KB  |  58 lines

  1. #ifndef Py_COMPILE_H
  2. #define Py_COMPILE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Definitions for bytecode */
  8.  
  9. /* Bytecode object */
  10. typedef struct {
  11.     PyObject_HEAD
  12.     int co_argcount;    /* #arguments, except *args */
  13.     int co_nlocals;        /* #local variables */
  14.     int co_stacksize;    /* #entries needed for evaluation stack */
  15.     int co_flags;        /* CO_..., see below */
  16.     PyObject *co_code;    /* instruction opcodes */
  17.     PyObject *co_consts;    /* list (constants used) */
  18.     PyObject *co_names;    /* list of strings (names used) */
  19.     PyObject *co_varnames;    /* tuple of strings (local variable names) */
  20.     /* The rest doesn't count for hash/cmp */
  21.     PyObject *co_filename;    /* string (where it was loaded from) */
  22.     PyObject *co_name;    /* string (name, for reference) */
  23.     int co_firstlineno;    /* first source line number */
  24.     PyObject *co_lnotab;    /* string (encoding addr<->lineno mapping) */
  25. } PyCodeObject;
  26.  
  27. /* Masks for co_flags above */
  28. #define CO_OPTIMIZED    0x0001
  29. #define CO_NEWLOCALS    0x0002
  30. #define CO_VARARGS    0x0004
  31. #define CO_VARKEYWORDS    0x0008
  32.  
  33. extern DL_IMPORT(PyTypeObject) PyCode_Type;
  34.  
  35. #define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
  36.  
  37. #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
  38.  
  39. /* Public interface */
  40. #ifndef __SASC
  41. struct _node; /* Declare the existence of this type */
  42. #endif
  43. DL_IMPORT(PyCodeObject *) PyNode_Compile Py_PROTO((struct _node *, char *));
  44. DL_IMPORT(PyCodeObject *) PyCode_New Py_PROTO((
  45.     int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
  46.     PyObject *, PyObject *, int, PyObject *)); /* same as struct above */
  47. DL_IMPORT(int) PyCode_Addr2Line Py_PROTO((PyCodeObject *, int));
  48.  
  49. /* for internal use only */
  50. #define _PyCode_GETCODEPTR(co, pp) \
  51.     ((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
  52.      ((co)->co_code, 0, (void **)(pp)))
  53.  
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* !Py_COMPILE_H */
  58.